<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE html>
<html lang="zh-cn">
<head>
<title>家庭档案列表</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport"
	content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="renderer" content="webkit">
<link rel="stylesheet" href="<%=path%>/css/pintuer.css">
<link rel="stylesheet" href="<%=path%>/css/admin.css">
<link rel="shortcut icon" href="<%=path%>/images/login.jfif">
<script src="<%=path%>/js/jquery.js"></script>
</head>
<body>


	<div class="panel admin-panel">
		<div class="panel-head">
			<strong class="icon-reorder"> 家庭档案列表</strong>
		</div>
		<div class="padding border-bottom">
			<ul class="search" style="padding-left:10px;">
				<li><a class="button border-main icon-plus-square-o"
					href="<%=path%>/family/family_add"> 添加家庭档案信息</a></li>
				<li>搜索：</li>
				<li>
					<form method="post" action="<%=path%>/family/family_list">
						<input type="text" placeholder="请输入搜索关键字" name="keyword" value=""
							class="input"
							style="width:250px; line-height:17px;display:inline-block" /> <input
							type="submit" class="button border-main icon-search" value="搜索">
					</form>
				</li>
			</ul>
		</div>
		<table class="table table-hover text-center">
			<tr>
				<th width="90" style="text-align:center;">&nbsp;</th>
				<th>县级编码</th>
				<th>乡镇编码</th>
				<th>村编码</th>
				<th>组编码</th>
				<th>家庭编号</th>
				<th>户主</th>
				<th>操作</th>
				

			</tr>
			<c:forEach items="${page.list}" var="family">
				<tr>

					<td><input type="checkbox" name="ids" value="" /></td>
					<td>${family.area_county_id}</td>
					<td>${family.area_town_id}</td>
					<td>${family.area_village_id}</td>
					<td>${family.area_team_id}</td>
					<td>${family.family_id}</td>
					<c:forEach items="${family.members}" var="member">
					<td>${member.member_name}</td>
				
					</c:forEach>
					<td><div class="button-group">
							<a class="button border-main"
								href="<c:url value='http://127.0.0.1:8080/mxbbx_lzs/family/family_update?family_id=${family.family_id}'/>"><span
								class="icon-edit"></span> 修改</a><a class="button border-red delete_btn"  href=""
                                     id="delete"  onclick="deleteFamily(${family.family_id})"><span class="icon-trash-o"></span> 删除</a>
						</div></td>
				</tr>
			</c:forEach>

		</table>
		<div class="pagelist">

			<div>共有${page.totalRecord}条记录，共${page.totalPage }页，当前为第${page.pageNum}页</div>
			<br /> <a
				href="http://127.0.0.1:8080/mxbbx_lzs/family/family_list?pageNum=1">首页</a>
			<%--如果当前页为第一页时，就没有上一页这个超链接显示 --%>
			<c:if test="${page.pageNum ==1}">
				<c:forEach begin="${page.start}" end="${page.end}" step="1" var="i">
					<c:if test="${page.pageNum == i}">
                        ${i}
                    </c:if>
					<c:if test="${page.pageNum != i}">
						<a
							href="http://127.0.0.1:8080/mxbbx_lzs/family/family_list?pageNum=${i}">${i}</a>
					</c:if>
				</c:forEach>
				<a
					href="http://127.0.0.1:8080/mxbbx_lzs/family/family_list?pageNum=${page.pageNum+1}">下一页</a>
			</c:if>

			<%--如果当前页不是第一页也不是最后一页，则有上一页和下一页这个超链接显示 --%>

			<c:if test="${page.pageNum > 1 && page.pageNum < page.totalPage}">
				<a
					href="http://127.0.0.1:8080/mxbbx_lzs/family/family_list?pageNum=${page.pageNum-1}">上一页</a>
				<c:forEach begin="${page.start}" end="${page.end}" step="1" var="i">
					<c:if test="${page.pageNum == i}">
                        ${i}
                    </c:if>
					<c:if test="${page.pageNum != i}">
						<a
							href="http://127.0.0.1:8080/mxbbx_lzs/family/family_list?pageNum=${i}">${i}</a>
					</c:if>
				</c:forEach>
				<a
					href="http://127.0.0.1:8080/mxbbx_lzs/family/family_list?pageNum=${page.pageNum+1}">下一页</a>
			</c:if>

			<%-- 如果当前页是最后一页，则只有上一页这个超链接显示，下一页没有 --%>
			<c:if test="${page.pageNum == page.totalPage && page.pageNum!=1}">
				<a
					href="http://127.0.0.1:8080/mxbbx_lzs/family/family_list?pageNum=${page.pageNum-1}">上一页</a>
				<c:forEach begin="${page.start}" end="${page.end}" step="1" var="i">
					<c:if test="${page.pageNum == i}">
                        ${i}
                    </c:if>
					<c:if test="${page.pageNum != i}">
						<a
							href="http://127.0.0.1:8080/mxbbx_lzs/family/family_list?pageNum=${i}">${i}</a>
					</c:if>
				</c:forEach>
			</c:if>
			<%--尾页 --%>
			<a
				href="http://127.0.0.1:8080/mxbbx_lzs/family/family_list?pageNum=${page.totalPage}">尾页</a>
		</div>
	</div>

</body>
<script type="text/javascript">
function deleteFamily(family_id){
    $.ajax({
       url:"<%=path%>/family/family_delete",
       type:"get",
       data:{family_id:family_id},
       async:false,
       success:function(res){
       console.log("处理信息:"+res)
           if(res.code==100){
           
           alert("删除成功");
           
           }else{
           
           alert("该家庭存在业务记录，无法删除！");
           
           }
       }
    })
}

</script>
</html>
